﻿var i = 1;
jQuery(function($){
	
	//$('.adArea').html('<div id="zxadArea"> </div>  <div id="zxw_indexad"><a href="../../../../../../idigger.allyes.com/main/c@db=idigger_2Fbid=53869,25967,1_2Fcid=23875,18697,1342_2Fsid=53007_2Fshow=ignore_2Furl=http_3A_2F_2Fwap.buick.com.cn"> <img src="../../../../../images/index_ad.jpg"> </a></div> ');
	
	  //添加广告
	  $(".myshare").css("margin-bottom","0");
	   //广告位
   // $(".myshare").after('   <div class="content_ad_1"> <A HREF="../../../../../../finance.chinanews.com/it/z/mind2013/index.shtml" target="_top"> <img src="../../../../../../www.chinanews.com/fileftp/2013/05/2013-05-27/qq300-45.gif"> </a> </div>');
    
	var islastpage= "0";
		var li = $("#picview li").each(function(i){
			 if(i==0){
					$(this).css('display','block'); 
					
					$("#picview li a").html("");
				}else
					{
									$(this).css('display','none'); 
					}
			});
		

			
		
			var picBox1 = $(".picBox").each(function(i){
				
				if (i==0){
				
							var li1 = $(".list li").each(function(i){
									$(this).css('display','block'); 
							});
							
				}
				else{
					$(this).css('display','none'); 
					$("#myform").css('display','none'); 
				}
					
			});
			
			
		$(".htmlcontent > p").each(function(i){
				$(this).css('font-size','14px');
				$(this).css('color','#fff');
				if(i>0){
						$(this).css('padding','15px 10px');
					}
			});
		
	/*	var d1 = $(".htmlcontent li h6 img").css("height");
		$("#apDiv1").css("height",d1);
		$("#apDiv2").css("height",d1);*/
			
		function loadimg() {

			if($(".htmlcontent li h6 img").length >0){

				var d1 = $(".htmlcontent li h6 img").css("height");
				var imgheight = $(".htmlcontent li h6 img").height();
				if (imgheight<=20){

					$("#apDiv1").css("height","50px");
					$("#apDiv2").css("height","50px");
				}else{

					$("#apDiv1").css("height",d1);
					$("#apDiv2").css("height",d1);
					
					
					imgheight = imgheight/2 + $("#header").height()+$("#header2").height();
					
					$("#left_btn").css("top",imgheight);
					$("#reght_btn").css("top",imgheight);
					
					if(islastpage =="0"){
						$("#left_btn").css("display","block");
						$("#reght_btn").css("display","block");
						$(".myshare").css("display","block");
					}
				}
			}
			if($(".htmlcontent p img").length >0){

				var d1 = $(".htmlcontent p img").css("height");
				var imgheight = $(".htmlcontent p img").height();
				
				if (imgheight<=20){

					$("#apDiv1").css("height","50px");
					$("#apDiv2").css("height","50px");
				}else{

					$("#apDiv1").css("height",d1);
					$("#apDiv2").css("height",d1);
					
					
					imgheight = imgheight/2 + $("#header").height()+$("#header2").height();
					
					$("#left_btn").css("top",imgheight);
					$("#reght_btn").css("top",imgheight);
					
					if(islastpage =="0"){
						$("#left_btn").css("display","block");
						$("#reght_btn").css("display","block");
						$(".myshare").css("display","block");
					}
				}
			
			}
			if($(".htmlcontent img").length >0){

				var d1 = $(".htmlcontent img").css("height");
				var imgheight = $(".htmlcontent img").height();
						 
				if (imgheight<=20){

					$("#apDiv1").css("height","50px");
					$("#apDiv2").css("height","50px");
				}else{

					$("#apDiv1").css("height",d1);
					$("#apDiv2").css("height",d1);
					
					
					imgheight = imgheight/2 + $("#header").height()+$("#header2").height();
					
					$("#left_btn").css("top",imgheight);
					$("#reght_btn").css("top",imgheight);
					
					if(islastpage =="0"){
						$("#left_btn").css("display","block");
						$("#reght_btn").css("display","block");
						$(".myshare").css("display","block");
					}
				}
			}
					
		};
		
		
		window.onload= loadimg;
			
			if($('.pageList').find('li').length){
			
				var plist = $(".pageList li a");
				var pagecount = $(".pageList li a").length;
				var url = $(".pageList .current a").attr("href");
				
			
				
				var i3 = url.lastIndexOf('/');
				  i3++;
				var tempurl = url.substring(i3);  
			
				var i1= tempurl.lastIndexOf('_');
				var i2= tempurl.lastIndexOf(".htm");
			
				var i4 = i1+1;
				var currentpage = tempurl .substring(i4,i2);
				
				var cpage = currentpage;
				var nextpageurl = "";
				var lastpageurl="";
				var i5 =0;
				if(i1==-1){
					nextpageurl =$(".pageList li a").get(1).href;
				  i5 =nextpageurl.lastIndexOf('/');
					i5++;
					nextpageurl =nextpageurl.substring(i5);
					
							$("#index").html("1");
							var pc = pagecount-1;
							$("#index2").html("../../../../../"+pc);
							//$("#apDiv1").attr("href",location.href.trim());
							//$("#apDiv2").attr("href",nextpageurl);
					}
				else{
					var lpage = parseInt(cpage) -2;
					if( cpage==2){lpage=0;}
					
					if(cpage == pagecount){
						//最后一页
						//$("#apDiv1").remove();
						//$("#apDiv2").remove();
						$("#index2").remove();
						$(".classname span").html("精彩推荐");
						$(".classname span").css("font-size","18px");
						$(".classname span").css("padding-left","14px");
						$(".lg_homeimage_btn").css("display","block");
						$("#index").html('<a id="refresh" class="right_btn" href="../../../../../default.htm">&nbsp;&nbsp;</a>');
						$("title").html("精彩推荐");
						$("#left_btn").css("display","none");
						$("#reght_btn").css("display","none");
						$(".picBox li").each(function(i){
								$(this).css('display','block'); 
						});
						
						$(".piclist").css("display","none");
						
						$(".pic_arctop").css("display","none");
						
						var url2= window.location.href;
						
						if(url2.indexOf('/iphone6/')>=0){
							$("#refresh").css("display","none");
							$(".right_btn").css("width","52px");
							$(".right_btn").css("height","49px");
						}
						
						islastpage ="1";
					}else{
						
						nextpageurl = $(".pageList li a").get(cpage).href;
						i5 =nextpageurl.lastIndexOf('/');
						i5++;
						nextpageurl =nextpageurl.substring(i5);
						lastpageurl = $(".pageList li a").get(lpage).href;
						i5 =lastpageurl.lastIndexOf('/');
						i5++;
						lastpageurl =lastpageurl.substring(i5);
						if(isNaN(currentpage)){
							//错误
						}
						else {
							$("#index").html(currentpage);
							var pc2= pagecount-1;
							$("#index2").html("../../../../../"+pc2);
							//$("#apDiv1").attr("href",lastpageurl);
							//$("#apDiv2").attr("href",nextpageurl);
						}
					}
				}
			}
			
			
});

function gotoHdlis(url){
	window.location.href ="../../../../../"+url;
}
